package com.george.user.controller;

import com.george.common.entity.dto.user.ScbUserDTO;
import com.george.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Create By George on /2023/4/10
 * description: 用户服务控制器
 *
 * @author George
 */
@Api(tags = "用户模块")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @ApiImplicitParam(name = "userId", value = "用户ID", required = true)
    @ApiOperation(value = "根据用户ID获取用户信息")
    @GetMapping("/getUserInfoById/{userId}")
    public ScbUserDTO getUserInfoById(@PathVariable("userId") Long userId) {
        return userService.getUserInfoById(userId);
    }


    @ApiImplicitParam(name = "name", value = "用户名称", required = true)
    @ApiOperation(value = "根据用户名称获取用户信息")
    @GetMapping("/getUserInfoByName/{name}")
    public ScbUserDTO getUserInfoByName(@PathVariable("name") String name) {
        return userService.getUserInfoByName(name);
    }

    @ApiImplicitParam(name = "name", value = "登录用户名称", required = true)
    @ApiOperation(value = "根据登录用户名称获取用户信息")
    @GetMapping("/getUserInfoByUsername/{username}")
    public ScbUserDTO getUserInfoByUsername(@PathVariable("username") String username) {
        return userService.getUserInfoByUsername(username);
    }

    @ApiOperation(value = "修改用户信息")
    @PostMapping("/updateUserInfoById}")
    public ScbUserDTO getUserInfoById(@RequestBody ScbUserDTO scbUserDTO) {
        return userService.updateUserInfoById(scbUserDTO);
    }
}
